set(CMAKE_POSITION_INDEPENDENT_CODE ON)

## WorkerTool

if (BUILD_TEST)
    # 创建静态库
    add_library(workertool_lib STATIC src/WorkerTool.cpp)
 
 
    # 公开头文件目录
    target_include_directories(workertool_lib PUBLIC
        ${CMAKE_CURRENT_SOURCE_DIR}/include
        ${ROOT_DIR}/common/thread-pool/include  
        ${COMMON_DIR}/include
        ${ROOT_DIR}/kvcache-memorypool/include
    )
 
    # 链接依赖库（如果有）
    target_link_libraries(workertool_lib PRIVATE
        common_lib
    )

    if(DEVICE STREQUAL "GPU")
        target_include_directories(workertool_lib PUBLIC ${CUDA_INC_DIR})
        target_link_libraries(workertool_lib PRIVATE ${CUDA_LIBRARIES})
    endif()
else()
    # 定义 Python 模块绑定
    add_library(WorkerTool MODULE       # 绑定代码文件
        src/WorkerTool.cpp
    )

    # 包含目录
    target_include_directories(WorkerTool PRIVATE
        ${CMAKE_CURRENT_SOURCE_DIR}/include
        ${pybind11_INCLUDE_DIRS}
        ${ROOT_DIR}/common/thread-pool/include
        ${COMMON_DIR}/include
    )

    if(DEVICE STREQUAL "GPU")
        target_include_directories(WorkerTool PRIVATE ${CUDA_INC_DIR})
    endif()

    set_target_properties(WorkerTool PROPERTIES
        OUTPUT_NAME "WorkerTool"       # 生成的模块名（WorkerTool.so）
        PREFIX ""                      # 去除 lib 前缀
        SUFFIX ".so"                   # 指定后缀
    )

    # 链接依赖库
    target_link_libraries(WorkerTool PRIVATE
        common_lib
    )
endif()